#include <iostream>
#include <cstring>
using namespace std;

/*
	用虚继承来解决环状继承引发的两个问题
	   问题1：Animal被构建多次
	          浪费了存储空间，C++希望Animal只构建一次
	   问题2：豹子调用eat方法提示二义性
  	   
*/
class Animal
{
public:
	Animal()
	{
		cout<<"Animal无参构造了"<<endl;
	}
	void eat()
	{
		cout<<"Animal eat"<<endl;
	}
};

class Catamount:virtual public Animal  //猫科动物
{
public:
	Catamount()
	{
		cout<<"Catamount无参构造"<<endl;
	}
};

class Mammal:virtual public Animal //哺乳动物
{
public:
	Mammal()
	{
		cout<<"Mammal无参构造"<<endl;
	}
};


class Leopard:public Mammal,public Catamount
{
public:
	Leopard()
	{
		cout<<"Leopard无参构造"<<endl;
	}
};

int main(int argc,char **argv)
{
	Leopard l1;
	
	l1.eat();
	return 0;	
}